package com.hellobike.haxing.modules.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hellobike.haxing.modules.wms.dto.ExportStockPickDto;
import com.hellobike.haxing.modules.wms.dto.StockPickDto;
import com.hellobike.haxing.modules.wms.entity.StockPick;
import com.hellobike.haxing.modules.wms.mapper.StockPickMapper;
import com.hellobike.haxing.modules.wms.service.IStockPickService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: t_wms_stock_pick
 * @Author: haxing-boot
 * @Date:   2020-01-15
 * @Version: V1.0
 */
@Service
public class StockPickServiceImpl extends ServiceImpl<StockPickMapper, StockPick> implements IStockPickService {

    @Override
    public StockPick getByStkBatchLocId(Long fmStockId) {
        StockPick q = new StockPick();
        q.setStkBatchLocId(fmStockId);
        QueryWrapper<StockPick> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public boolean addStock(Long id, BigDecimal qty) {
        return baseMapper.addStock(id,qty) == 1;
    }

    @Override
    public List<StockPick> getBySkuId(Long skuId) {
        StockPick q = new StockPick();
        q.setSkuId(skuId);
        QueryWrapper<StockPick> queryWrapper = new QueryWrapper<>(q);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public boolean subStock(Long id, BigDecimal qty) {
        return baseMapper.subStock(id,qty) == 1;
    }

    @Override
    public IPage<StockPickDto> pageByStockPickDto(Page<StockPickDto> page, StockPickDto stockPick) {
        return baseMapper.pageByStockPickDto(page,stockPick);
    }

    @Override
    public List<ExportStockPickDto> exportStockPick(StockPickDto stockPick) {
        return baseMapper.exportStockPick(stockPick);
    }
}
